package com.dongdong.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdong.mapper.TbSellerMapper;
import com.dongdong.pojo.*;
import com.dongdong.service.SellerService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Deacription TODO
 * @Author Lenovo
 * @Date 2020/12/13 13:03
 * @Version 1.0
 **/
@Component
@Service
public class SellerServiceImpl implements SellerService {

    @Resource
    private TbSellerMapper sellerMapper;

    @Override
    public TbSeller getMessage(String id) {
        return sellerMapper.selectByPrimaryKey(id);
    }

    @Override
    public int saveRegister(TbSeller tbSeller) {
        return sellerMapper.insertSelective(tbSeller);
    }

    @Override
    public TbSeller findUserByUserName(String name) {
        TbSellerExample example = new TbSellerExample();
        TbSellerExample.Criteria criteria = example.createCriteria();
        criteria.andNameEqualTo(name);
        List<TbSeller> list = sellerMapper.selectByExample(example);
        return (list == null || list.size() == 0)? null: list.get(0);
    }

    @Override
    public int updateStatus(TbSeller tbSeller) {
        return sellerMapper.updateByPrimaryKeySelective(tbSeller);
    }

    @Override
    public List<TbSeller> getSeller(TbSeller tbSeller) {
        List<TbSeller> list = sellerMapper.getSeller(tbSeller);
        return list;
    }

    @Override
    public String getNameById(String sellerId) {
        return sellerMapper.getNameById(sellerId);
    }
}

